/*
 * Copyright © 2015 Cask Data, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */

@import "../../variables.less";
@import "../../../../bower_components/bootstrap/less/mixins.less";
@import "mixins.less";

body.theme-cdap {

  //
  // Full width for Dashboard
  // --------------------------------------------------
  &.state-dashboard {
    main.container {
      width: 100%;
    }
  }
  //
  // Alerts
  // --------------------------------------------------

  > div.alerts {
    div.alert {
      position: relative;
      padding-right: 30px;
    }
    button.close {
      font-size: 30px;
      line-height: 1;
      position: absolute;
      top: 2px;
      right: 15px;
    }
  }
  // Common styles
  .alert {
    border: 0;
    color: white;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.2);
    width: 100%;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
    margin-bottom: 0;
    padding-top: 10px;
    padding-bottom: 10px;
    .border-radius(0);
    @shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 2px rgba(0, 0, 0, 0.05);
    .box-shadow(@shadow);
    button.close {
      font-weight: 400;
      line-height: 12px;
      margin-left: 10px;
      text-shadow: none;
      .opacity(0.4);
      &:focus {
        outline: 0;
      }
    }
  }

  // Apply the mixin to the alerts
  .alert-success { background-color: @alert-success-bg; }
  .alert-info { background-color: @alert-info-bg; }
  .alert-warning { background-color: @alert-warning-bg; }
  .alert-danger { background-color: @alert-danger-bg; }

  //
  // Status text
  // --------------------------------------------------
  .text-success { color: @brand-success; }
  .text-danger { color: @brand-danger; }
  .text-warning { color: @brand-warning; }

  //
  // Status background-color
  // --------------------------------------------------
  .bg-success { background-color: @brand-success; }
  .bg-danger { background-color: @brand-danger; }

  //
  // Progress bars
  // --------------------------------------------------

  .pagination {
    > li {
      > a,
      > span {
        color: @cdap-header;
      }
    }
    > .active {
      > a,
      > span {
        background-color: @cdap-header;
        border-color: @cdap-header;
        color: white;
        &:hover,
        &:focus {
          background-color: @cdap-header;
          border-color: @cdap-header;
        }
      }
    }
  }

  //
  // Progress bars
  // --------------------------------------------------

  // Give the progress background some depth
  .progress {
    #gradient > .vertical(@start-color: darken(@progress-bg, 4%); @end-color: @progress-bg);
  }

  // Mixin for generating new styles
  .progress-bar-styles(@color) {
    #gradient > .vertical(@start-color: @color; @end-color: darken(@color, 10%));
  }

  // Apply the mixin to the progress bars
  .progress-bar { .progress-bar-styles(@progress-bar-bg); }
  .progress-bar-success { .progress-bar-styles(@progress-bar-success-bg); }
  .progress-bar-info { .progress-bar-styles(@progress-bar-info-bg); }
  .progress-bar-warning { .progress-bar-styles(@progress-bar-warning-bg); }
  .progress-bar-danger { .progress-bar-styles(@progress-bar-danger-bg); }

  // Reset the striped class because our mixins don't do multiple gradients and
  // the above custom styles override the new `.progress-bar-striped` in v3.2.0.
  .progress-bar-striped {
    #gradient > .striped();
  }

  //
  // Tables
  // --------------------------------------------------

  .table {
    background-color: @table-bg;
    margin-top: 10px;
    &[cask-sortable] {
      thead {
        .empty { cursor: default; }
      }
    }
    tbody {
      color: @cdap-darkness;
      a {
        &:not(.btn-success) {
          color: @cdap-bluegray;
        }
        &:hover,
        &:focus {
          cursor: pointer;
          text-decoration: none;
        }
        &.btn-danger { .cask-btn(@background: transparent, @border: 0, @border-radius: 0, @color: @brand-danger, @padding: 0); }
      }
    }
    th,
    td {
      padding: 10px;
      &:hover,
      &:focus {
        outline: none;
      }
    }
    th {
      font-size: 16px;
      &:hover,
      &:focus {
        background-color: transparent;
        cursor: pointer;
      }
    }
    td { font-size: 14px; }

    &[cask-sortable] {
      tr.sort-enabled th:hover { background-color: transparent; }
    }
  }

  // Add table-curved class for curved table edges
  .table-curved {
    border-collapse: separate;
    border: 1px solid @table-border-color;
    .border-radius(8px);
    border-left: 0;
    thead {
      tr {
        th {
          font-weight: 400;
        }
      }
    }
    td,
    th {
      border-left: 1px solid @table-border-color;
      border-top: 1px solid @table-border-color;
    }
    th {
      border-top: 0;
      border-bottom: 0;
      &:first-child { .border-radius(@table-radius 0 0 0); }
      &:last-child { .border-radius(0 @table-radius 0 0); }
      &:only-child { .border-radius(@table-radius @table-radius 0 0); }
    }
    tr:last-child {
      & > td:first-child { .border-radius(0 0 0 @table-radius); }
      & > td:last-child { .border-radius(0 0 @table-radius 0); }
      & > td:only-child { .border-radius(0 0 @table-radius @table-radius); }
    }
  }

  // ui-view[role="tabpanel"] .table:not([cask-sortable])
  .table.table-status {
    th,
    td {
      border-left: 0;
      &:first-child { border-right: 1px solid @table-border-color; }
    }
    th {
      color: @cdap-header;
      cursor: default;
    }
    td {
      border-top: 0;
      strong {
        color: @cdap-header;
        display: block;
        font-size: 18px;
        line-height: 1;
      }

      @media (min-width: @screen-md-min) {
        .row .col-xs-6:first-child > div {
          border-right: 1px solid @table-border-color;
          width: 75%;
        }
      }
    }
  }

  .instances .table {
    tbody { background-color: white; }
    td { border: 0; }
  }
  //
  // List groups
  // --------------------------------------------------

  .list-group {
    .border-radius(@border-radius-base);
    .box-shadow(0 0px 0px rgba(0,0,0,.075));
  }
  .list-group-item.active,
  .list-group-item.active:hover,
  .list-group-item.active:focus {
    text-shadow: 0 -1px 0 darken(@list-group-active-bg, 10%);
    #gradient > .vertical(@start-color: @list-group-active-bg; @end-color: darken(@list-group-active-bg, 7.5%));
    border-color: darken(@list-group-active-border, 7.5%);
    .badge { text-shadow: none; }
  }

  //
  // Panels
  // --------------------------------------------------

  // Message panel (appears on Dev + Management start screens)
  .panel-message {
    background: white;
    border: 1px solid #d1d4dc;
    margin-bottom: 20px;
    padding: 10px;
    .border-radius(4px);
    p { margin-bottom: 0; }
    .btn-close {
      .cask-btn(@background: @cdap-lightgray, @border: 0, @border-radius: 28px, @padding: 0);
      cursor: pointer;
      line-height: 0;
      .fa-close {
        color: white;
        padding: 8px 10px;
        vertical-align: text-top;
      }
    }
  }

  .panel { .box-shadow(none); }

  .panel-title {
    span.fa {
      font-size: 10px;
      margin-right: 10px;
      height: 15px;
      vertical-align: middle;
      .border-radius(25px);
    }
  }
  .panel-explore {
    background-color: transparent;
    color: @cdap-header;
    > .panel-heading {
      background: white;
      border: 1px solid lightgray;
      padding: 20px;
      cursor: pointer;
      .border-radius(8px);
    }
    > .panel-collapse {
      > .panel-body {
        border-top: 0;
        padding-right: 0;
        padding-left: 0;
        pre {
          background-color: #dcdce4;
          color: @cdap-header;
          .border-radius(4px);
        }
      }
    }
  }
  // Mixin for generating new styles
  .panel-heading-styles(@color) {
    #gradient > .vertical(@start-color: @color; @end-color: darken(@color, 5%));
  }

  // Apply the mixin to the panel headings only
  .panel-default > .panel-heading {
    background: @cdap-lightgray;
    border: 0;
  }
  .panel-primary > .panel-heading { .panel-heading-styles(@panel-primary-heading-bg); }
  .panel-success > .panel-heading { .panel-heading-styles(@panel-success-heading-bg); }
  .panel-info > .panel-heading { .panel-heading-styles(@panel-info-heading-bg); }
  .panel-warning > .panel-heading { .panel-heading-styles(@panel-warning-heading-bg); }
  .panel-danger > .panel-heading { .panel-heading-styles(@panel-danger-heading-bg); }

  //
  // Wells
  // --------------------------------------------------

  .well {
    background-color: #dcdce4;
    border-color: darken(@well-bg, 10%);

    @shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 0 rgba(255, 255, 255, 0.1);
    .box-shadow(@shadow);
    p {
      color: @cdap-header;
    }
    a {
      cursor: pointer;
    }
    *:only-child { margin: 0; }
    &.dark {
      margin-top: 0;
      background: @cdap-darkness;
    }
  }

  //
  // Modals
  // --------------------------------------------------
  .modal {
    // Modal layout styles (container elements)
    &.center {
      .modal-dialog {
        max-width: 80%;

        @media (min-width: @screen-md-min) {
          width: 900px;
        }
      }
      .modal-sm {
        max-width: 630px;
      }
    }

    &.hydrator-modal,
    &.tracker-modal {
      .modal-dialog {
        margin-top: 100px;
        .border-radius(4px);
      }
      // Large modals
      .modal-lg {
        .panel {
          background-color: transparent;
        }
        .fa-plus {
          padding-top: 2px;
        }
        .modal-footer {
          text-align: right;
        }
      }
      // Small modals (ie, cask-confirmable, cask-promptable)
      .modal-sm {
        text-align: center;
        .modal-footer {
          text-align: center;
        }
      }
      .modal-header {
        background-color: @body-bg;
        border-bottom: 1px solid @modal-table-border-color;
        height: 60px;
        margin-bottom: 5px;
        padding: 0;
        .border-radius(4px 4px 0 0);
        .box-shadow(0 0 10px fade(black, 50%));
        > div {
          margin: 0;
          padding-left: 15px;

          @media (max-width: @screen-sm-max) {
            max-width: 200px;
          }
          h3,
          p {
            @media (max-width: @screen-sm-max) {
              white-space: nowrap;
              text-overflow: ellipsis;
              overflow: hidden;
            }
          }
          h3 {
            padding-top: 5px;
            &:only-child {
              line-height: 60px;
              padding-top: 0;
            }
          }
        }
        > h3 {
          line-height: 60px;
          padding-left: 15px;

          @media (max-width: @screen-sm-max) {
            max-width: 200px;
            white-space: nowrap;
            text-overflow: ellipsis;
            overflow: hidden;
          }
        }
        h3 {
          color: @cdap-header;
          font-weight: 500;
          margin: 0;
          &:only-child {
            line-height: 60px;
            padding-top: 0;
          }
        }
        p {
          color: @cdap-lightgray;
          margin: 0;
          max-width: 740px;
        }
        > a.btn {
          .cask-btn(@background: transparent, @border: 1px solid transparent, @border-radius: 0, @color: @cdap-header, @font-size: 18px, @padding: 0);
          border-left: 1px solid @modal-table-border-color;
          width: 60px;
          height: 60px;
          line-height: 60px;
          .transition(all 0.2s ease);
          &:hover,
          &:focus {
            background-color: @cdap-header;
            border: 1px solid @cdap-header;
            color: white;
            .border-radius(0 4px 0 0);
          }
        }
      }
      .modal-content {
        color: @cdap-header;
        background-color: white;
      }
      .modal-body {
        padding: 10px;
        width: 100%;
        div.alerts {
          top: 60px;
        }
      }
      .modal-footer {
        border-top: 0;
      }

      // Modal content styling (headings, forms, tables, etc.)
      h3,
      h4 {
        color: @cdap-header;
      }
      .control-label {
        font-weight: 400;
      }
      .form-control {
        .border-radius(4px);
        .box-shadow(none);
        text-align: left;
        &:focus {
          .box-shadow(none);
        }

        // Metric picker specific styles.
        &.mp-dropdown-toggle {
          .border-radius(4px 0 0 4px);
          border-right: 1px solid #cccccc;
        }

        &.mp-input-group-input {
          .border-radius(0 4px 4px 0);
        }
      }
      .input-group-addon + .form-control {
        border-left: 1px solid lightgray;
        .border-radius(0 4px 4px 0);
      }
      textarea.form-control {
        min-height: 100px;
        resize: none;
      }
      button.form-control:focus {
        outline: none;
      }
      .btn[disabled] {
        background-color: rgb(192, 192, 192);
        color: @cdap-header;
      }
      .table {
        background-color: white;
        border: 1px solid @modal-table-border-color;
        margin: 0;
        thead th {
          border-right: 1px solid @modal-table-border-color;
          border-bottom-width: 1px;
          color: @cdap-header;
        }
        tbody {
          text-align: left;
          td {
            border-right: 1px solid @modal-table-border-color;
            padding-right: 8px;
            padding-left: 8px;
          }
        }
      }
      .pagination {
        margin: 0 0 10px;
      }
      .alert.alert-danger.alert-dismissible {
        padding: 5px;
        margin-bottom: 0;
        .close {
          right: 0;
        }
      }
    }
  }

  //
  // Tooltips
  // --------------------------------------------------
  .tooltip {
    font-size: 11px;
    &.top {
      margin-top: -2px;
      .tooltip-arrow {
        bottom: 1px;
        left: 50%;
        margin-left: -5px;
        border-left: 5px solid transparent;
        border-right: 5px solid transparent;
        border-top: 5px solid @cdap-header;
      }
    }
    &.right {
      margin-left: 2px;
      .tooltip-arrow {
        top: 50%;
        left: 1px;
        margin-top: -5px;
        border-top: 5px solid transparent;
        border-bottom: 5px solid transparent;
        border-right: 5px solid @cdap-header;
      }
    }
    &.bottom {
      margin-top: -2px;
      .tooltip-arrow {
        top: 1px;
        left: 50%;
        margin-left: -5px;
        border-left: 5px solid transparent;
        border-right: 5px solid transparent;
        border-bottom: 5px solid @cdap-header;
      }
    }
    &.left {
      margin-left: -2px;
      .tooltip-arrow {
        top: 50%;
        right: 1px;
        margin-top: -5px;
        border-top: 5px solid transparent;
        border-bottom: 5px solid transparent;
        border-left: 5px solid @cdap-header;
      }
    }
  }
  .tooltip-inner {
    background-color: @cdap-header;
    border: 1px solid @cdap-header;
    color: white;
    padding: 7px;
    word-wrap: break-word;
    text-align: left;
    .border-radius(3px);
  }

}
